<template>
	<view class="bgf8">
		<view class="tabchange" v-for="(item,index) in list" :key="index" @click="detail(item.order_id,item.id)"> 
			<view class="uniBtn">
				<view class="left_info">
					{{item.user.name}}
					<text class="sex"><text v-if="item.user.sex==1">男</text><text v-else>女</text></text>
					<text>{{item.user.nianling}}</text>
				</view>
				<view :class="[item.status==0?'stu3':'',item.status==1?'stu1':'',item.status==2?'stu2':'',item.status==3?'stu':'',item.status==4?'stu4':'']">{{item.status_str}}</view>
			</view>
			<view>会诊医生：{{item.h_name}}</view>
			<view>描述：{{item.miaoshu}}</view>
			<view>时间：{{item.add_time}}</view>
			<view class="uniBtn">
				<view></view>
				<view class="stu">￥{{item.price}}</view>
			</view> 
		</view>
		
		<view class="base" @click="add">
			<text>{{name}}</text>
		</view>
	</view>
</template>

<script>
	import {
		huizhen,gethuizhen
	} from '../../request/api.js'
	export default {
		data() {
			return {
				page: 1,
				pages: 0,
				list:[
					// {id:1,code:'O7688162291944988',type:'自取',type2:'云药房',status:0,statusName:'待支付'},
					// {id:1,code:'O7688162291944988',type:'快递',type2:'本地',status:1,statusName:'待接单'},
					// {id:1,code:'O7688162291944988',type:'快递',type2:'本地',status:2,statusName:'待发药'},
					// {id:1,code:'O7688162291944988',type:'快递',type2:'本地',status:3,statusName:'已发药'},
					// {id:1,code:'O7688162291944988',type:'快递',type2:'本地',status:4,statusName:'已签收'}
				],
				name:'添加\n会诊'
			}
		},
		onShow() {
			this.list = [];
			this.getList(1)
		},
		onReachBottom: function() {
			//触底的时候请求数据，即为上拉加载更多
			this.page++;
			if (this.page > this.pages) {
				uni.hideNavigationBarLoading();
				uni.showToast({
					title: '暂无更多数据',
					icon: 'none'
				})
			} else {
				this.getList(this.page);
			}
		},
		methods: {
			// 添加会诊
			add(){
				uni.navigateTo({
					url:'/pages/guahao/huizhen'
				})
			},
			// 去开方
			kaifang(id){
				uni.navigateTo({
					url:'/pages/guahao/kaifang?id='+id
				})
			},
			// 列表
			getList(page) {
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				huizhen({
					page: page,
					listRows: 20
				}).then(res => {
					this.pages = res.totalPages;
					if (this.page == 1) {
						this.list = res.data;
						if (this.list.length === 0 || this.list.length === '0') {
							uni.showToast({
								icon: 'none',
								duration: 3000,
								title: '暂无数据'
							});
							return
						}
					} else {
						this.list = this.list.concat(res.data);
					}
					uni.hideLoading()
					uni.hideNavigationBarLoading()
				})
			},
			detail(oid,id){
				if(oid){
					uni.navigateTo({
						url:'/pages/myOrder/detail?id='+oid
					})
				}else{
					gethuizhen({id:id}).then(res=>{
						if(res.data.oid){
							uni.navigateTo({
								url:'/pages/myOrder/detail?id='+res.data.oid
							})
						}else{
							uni.showToast({
								title:'会诊未开方，请稍后重试!',
								icon:'none'
							})
							// uni.navigateTo({
							// 	url:'/pages/guahao/doctors?id='+id
							// })
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background: #f8f8f8;
	}
	.base{
		position: fixed;
		right: 55upx;
		bottom: 55upx;
		font-size: 26upx;
		background-color: #F87D53;
		color: #ffffff;
		border-radius: 50%;
		width: 100upx;
		height: 100upx;
		text-align: center;
		line-height: 30upx;
		padding: 20upx;
	}
	.tabchange {
		background: #ffffff;
		margin: 20upx 0;
		padding: 30upx;
		line-height: 160%;
		font-size: 30upx;
		
		.left_info{
			font-size: 28upx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #414141;
			
			text {
				font-weight: 200;
			}
			
			.sex {
				padding: 0 24upx;
				margin: 0 24upx;
				border-left: 2upx solid #CCCCCC;
				border-right: 2upx solid #CCCCCC;
			}
		}
		.stu{
			color: #EE2727;
		}
		.stu1{
			color: #009688;
		}
		.stu2{
			color: #008000;
		}
		.stu3{
			color: #FFB800;
		}
		.stu4{
			color: #666666;
		}
		.stu5{
			margin: 0 15upx;
		}
		.stu6-7{
			color: #ffffff;
			font-size: 26upx;
			padding: 3upx 10upx;
			border-radius: 5upx;
		}
		.stu6{
			background: #1E9FFF;
		}
		.stu7{
			background: #DEA512;
		}
		.last{
			color: #6996FE;
			font-size: 24upx;
			border:1px solid #6996FE;
			border-radius: 26upx;
			padding: 10upx 30upx;
			width: 120upx;
			line-height: 100%;
			margin-top: 30upx;
		}
	}
</style>
